<fieldset class="layui-elem-field layui-field-title" style="text-align: center;">
    <legend>回帖</legend>
</fieldset>

<ul class="jieda" id="comment">
    <%for(comment in page.list){%>
    <li data-id="${comment.id}" class="jieda-daan">
        <div class="detail-about detail-about-reply">
            <a class="fly-avatar" href="">
                <img src="${ctxPath}/static/images/default.png" alt=" ">
            </a>
            <div class="fly-detail-user">
                <a href="" class="fly-link">
                    <cite>${comment.name}</cite>
                </a>
            </div>

            <div class="detail-hits">
                <span>${comment.createDate,dateFormat="yyyy-MM-dd HH:mm:ss"}</span>
            </div>

        </div>
        <div class="detail-body jieda-body photos">
            ${comment.content!}
        </div>
        <div class="jieda-reply">
            <span type="reply">
                <i class="iconfont icon-svgmoban53"></i>
                回复
            </span>
        </div>
    </li>
    <%}elsefor{%>
    <li class="fly-none">消灭零回复</li>
    <%}%>
</ul>
<div class="pagination">${page}</div>

<div class="layui-form layui-form-pane">
    <form method="post">
        <input type="hidden" name="category.id" value="${comment.category.id}"/>
        <input type="hidden" name="contentId" value="${comment.contentId}"/>
        <input type="hidden" name="title" value="${comment.title}"/>
        <input type="hidden" name="replyId" id="L_replyId" value=""/>
        <div class="layui-form-item layui-form-text">
            <div class="layui-input-block">
                <textarea id="L_content" name="content" required lay-verify="required" placeholder="请输入内容"  class="layui-textarea fly-editor" style="height: 150px;"></textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <button id="submitComment" class="layui-btn" lay-filter="comment" lay-submit>提交回复</button>
        </div>
    </form>
</div>
<script>
    //layui.cache.page ='jie';
    layui.cache.modules['jie'] = null;//删除jie模块，如下重新加载使所有的回复按钮重新绑定事件
    layui.use(['form','fly','face','jie'],function () {
        var $ = layui.$,fly = layui.fly,face=layui.face;
        //如果你是采用模版自带的编辑器，你需要开启以下语句来解析。
        $('.jieda-body').each(function () {
            var othis = $(this), html = othis.html();
            othis.html(fly.content(html));
        });
        var form = layui.form;
        form.on('submit(comment)', function(data){
            $.ajax({
                url:'${ctxFront}/comment',
                type:'post',
                dataType:'json',
                data:data.field,
                beforeSend:function(){ //触发ajax请求开始时执行
                    $("#submitComment").attr("disabled","true"); //改变提交按钮上的文字并将按钮设置为不可点击
                },
                success:function(result){
                    console.log(result);
                    if (result.code != 0 || result.code != '0') {
                        layer.msg(result.msg,{time: 500}, function(){
                            $("#submitComment").removeAttr("disabled"); //改变提交按钮上的文字并将按钮设置为可点击
                        });
                    } else {
                        layer.msg(result.msg,{time: 500},function () {
                            //window.location.reload();
                            page(1);
                        });
                    }
                },
                error:function(){
                    layer.msg("提交回复失败!",{time: 1000}, function(){
                        $("#submitComment").removeAttr("disabled"); //改变提交按钮上的文字并将按钮设置为可点击
                    });
                }
            });
            return false;
        });
    })
</script>